home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
BUG 1
/
BUGCD1996_0708.ISO
/
mac
/
Alati
/
GrafiËka pomagala
/
clip2gif 0.7.2.1
/
Calling clip2gif from C
/
LoadClip2Gif.c
< prev
next >
Wrap
Text File
|
1995-12-20
|
3KB
|
92 lines
/*
* LoadClip2Gif.c
*
* Copyright 1995, Yves Piguet. All rights reserved.
*/
#include <CodeFragments.h>
#include "LoadClip2Gif.h"
short (*GetVersionNumber)(void);
OSErr (*BeginOffscreen)(Offscreen *, short, short, short, CTabHandle);
OSErr (*DisposeOffscreen)(Offscreen *);
OSErr (*ConvertFileToPict)(PicHandle, Handle *);
OSErr (*ConvertPictToGIFFile)(PicHandle, FSSpec *, short, RGBColor *, short, CTabHandle);
OSErr (*ConvertPictToGIFHandle)(PicHandle, Handle *, short, RGBColor *, short, CTabHandle);
OSErr (*ConvertPixmapToGIFHandle)(PixMapHandle, Handle *, short, RGBColor *);
OSErr (*ConvertPixmapToGIFFile)(PixMapHandle, FSSpec *, short, RGBColor *);
OSErr (*ConvertPictToJPEGHandle)(PicHandle, Handle *, short, short);
OSErr (*ConvertPictToJPEGFile)(PicHandle, FSSpec *, short, short);
OSErr (*ConvertPictToTIFFHandle)(PicHandle, Handle *, short, short);
OSErr (*ConvertPictToTIFFFile)(PicHandle, FSSpec *, short, short);
OSErr (*GetScreen)(Rect *, PicHandle *);
#define ResolveSymbol(name,addr) do { \
err = FindSymbol(connID, name, (Ptr*)&addr, &symClass); \
if (err != noErr) \
return err; \
} while(0)
OSErr LoadClip2Gif(void)
{
DTPBRec paramBlock;
long dirID; // ignored (used by HGetVol)
Str63 appName;
FSSpec spec;
OSErr err;
ConnectionID connID;
Ptr mainAddr;
Str255 errName;
SymClass symClass;
// first checks in the same folder, so that older versions of clip2gif can be
// kept on the same volume
err = FSMakeFSSpec(0, 0, "\pclip2gif", &spec);
if (err != noErr) // not here; uses the Desktop Database
{
err = HGetVol(0L, ¶mBlock.ioVRefNum, &dirID);
paramBlock.ioNamePtr = appName;
err = PBDTGetPath(¶mBlock);
if (err != noErr)
return err;
paramBlock.ioCompletion = 0L;
paramBlock.ioNamePtr = appName;
paramBlock.ioIndex = 0;
paramBlock.ioFileCreator = 'c2gf';
err = PBDTGetAPPL(¶mBlock, 0);
if (err != noErr)
return err;
err = FSMakeFSSpec(0, paramBlock.ioAPPLParID, paramBlock.ioNamePtr, &spec);
}
if (err != noErr)
return err;
err = GetDiskFragment(&spec, 0, kWholeFork, "\pclip2gif",
kLoadLib, &connID, &mainAddr, errName);
if (err != noErr)
return err;
ResolveSymbol("\pGetVersionNumber", GetVersionNumber);
ResolveSymbol("\pBeginOffscreen", BeginOffscreen);
ResolveSymbol("\pDisposeOffscreen", DisposeOffscreen);
ResolveSymbol("\pConvertFileToPict", ConvertFileToPict);
ResolveSymbol("\pConvertPictToGIFHandle", ConvertPictToGIFHandle);
ResolveSymbol("\pConvertPictToGIFFile", ConvertPictToGIFFile);
ResolveSymbol("\pConvertPixmapToGIFHandle", ConvertPixmapToGIFHandle);
ResolveSymbol("\pConvertPixmapToGIFFile", ConvertPixmapToGIFFile);
ResolveSymbol("\pConvertPictToJPEGHandle", ConvertPictToJPEGHandle);
ResolveSymbol("\pConvertPictToJPEGFile", ConvertPictToJPEGFile);
ResolveSymbol("\pConvertPictToTIFFHandle", ConvertPictToTIFFHandle);
ResolveSymbol("\pConvertPictToTIFFFile", ConvertPictToTIFFFile);
ResolveSymbol("\pGetScreen", GetScreen);
if (GetVersionNumber() != 71)
return envBadVers;
return noErr;
}